package com.aabte.design2.creational.builder;


/**
 * @author Daniel
 * @version 1.0
 * @date 2020/5/2
 */
public class CarBuilder implements Builder {
    private Car car;

    public static Builder builder() {
        CarBuilder builder = new CarBuilder();
        builder.reset();
        return builder;
    }

    @Override
    public Car build() {
        Car car = this.car;
        this.reset();
        return car;
    }

    @Override
    public void reset() {
        this.car = new Car();
    }

    @Override
    public void seats(int number) {
        this.car.setSeats(number);
    }

    @Override
    public void engine(Engine engine) {
        this.car.setEngine(engine);
    }

    @Override
    public void tripComputer(boolean flag) {
        this.car.setTripComputer(flag);
    }

    @Override
    public void GPS(boolean flag) {
        this.car.setGPS(flag);
    }
}
